home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / flagbi.arc / FLAGBIG.PAS < prev   
Pascal/Delphi Source File  |  1989-10-10  |  6KB  |  194 lines

  1. {$A+,B-,D+,E+,F-,I+,L+,N-,O+,R+,S+,V+}
  2. {$M 16384,0,1600}
  3. PROGRAM FLAGBIG;
  4.  
  5. (* THIS PROGRAM RECURSIVELY SEARCHES AN ENTIRE VOLUME ON NETWARE AND FLAGS *)
  6. (* FILES LARGER THAN A CERTAIN SIZE WITH THE "INDEX" FLAG.  FLAGGED FILES  *)
  7. (* WILL HAVE THEIR FAT TABLES INDEXED AUTOMATICALLY BY NOVELL.             *)
  8. (* YOU MAY SPECIFY THE MINIMUM SIZE FOR FLAGGING ON THE COMMAND LINE OR    *)
  9. (* SELECT THE DEFAULT OF 500,000 BYTES.                                    *)
  10.  
  11.  
  12. (*  All software is copyrighted by Azatar MicroSystems     *)
  13. (*  and Lee Drake.  Code for this example may be copied    *)
  14. (*  for non-commercial applications as long as this notice *)
  15. (*  is included in the header.  All commercial use is      *)
  16. (*  specifically excluded.                                 *)
  17.  
  18.  
  19. USES DOS,CRT,ENGINE ;
  20.  
  21.  
  22. CONST DEFAULT_MIN_FILE_SIZE : LONGINT = 500000;
  23. VAR   ERR : INTEGER;                            { temporary error vars }
  24.       ERR2: BYTE;                               { temporary error vars }
  25.  
  26.  
  27. {$F+} PROCEDURE FLAGIT(VAR S : SEARCHREC; P:PATHSTR); {$F-}
  28.  
  29.  
  30. (*  This procedure, called by searchengineall, is the main procedure to *)
  31. (*  flag or unflag the files.  Index_on is a byte with the proper bit   *)
  32. (*  screen to turn on indexing when "or"ed with the current ext. attr.  *)
  33. (*  byte.  Index_off is the correct screen to use to turn off indexing  *)
  34. (*  when "and"ed with the current byte.                                 *)
  35. (*  NOTE - The format of the passed parameters above is fixed and cannot*)
  36. (*  be changed without changing the definitions for PROCTYPE in engine. *)
  37.  
  38.  
  39.  
  40. const index_on = $20;
  41.       index_off= $df;
  42.  
  43.  
  44. VAR   PZSTR     : ARRAY [1..255] OF CHAR;  {used to pass in the file path}
  45.  
  46.       TEMPSTR   : STRING;                  {Temporary Variable}
  47.       CH        : CHAR;                    {    "        "    }
  48.       INDEX_BIT : BYTE;                    {    "        "    }
  49.       REGS      : REGISTERS;               {    "        "    }
  50.       I         : BYTE;                    {    "        "    }
  51.  
  52.       EFA       : BYTE;                    {used to hold the Ext File Attr}
  53.  
  54.  
  55. BEGIN
  56.    {Don't want to look at or change directories}
  57.  
  58.    if (s.attr and directory) <> 0 then exit;
  59.  
  60.  
  61.  
  62.    IF S.SIZE < DEFAULT_MIN_FILE_SIZE THEN INDEX_BIT := index_off else
  63.      INDEX_BIT := index_on;
  64.  
  65.    TEMPSTR   := P+S.NAME;                  {join the path and file name}
  66.  
  67.    I := LENGTH(TEMPSTR);                   {Copy the path and file name}
  68.    WHILE (I > 0) DO                        {into the array             }
  69.    BEGIN
  70.       PZSTR[I] := TEMPSTR [I];
  71.       DEC(I);
  72.    END;
  73.    PZSTR[LENGTH(TEMPSTR)+1] := #0;         {Append an Ascii zero to the end}
  74.  
  75.  
  76.    { GET CURRENT EXTENDED FILE ATTRIBUTES }
  77.    WITH REGS DO
  78.    BEGIN
  79.       AH := $B6;
  80.       AL := $00;                           {get extended attribute}
  81.       DS := SEG (PZSTR);
  82.       DX := OFS (PZSTR);
  83.    END;
  84.    MSDOS (REGS);
  85.    IF REGS.AL <> 0 THEN
  86.    begin
  87.       { Get extended attributes failed }
  88.  
  89.       writeln('Failed to get attributes');
  90.       ch := readkey;
  91.       EXIT;
  92.    end;
  93.  
  94.    IF S.SIZE < DEFAULT_MIN_FILE_SIZE THEN
  95.    begin
  96.       {If size smaller and index off then exit}
  97.       if (regs.cl and index_on) = 0 then exit
  98.       else
  99.       {Size is smaller and index on, turn off?}
  100.       begin
  101.          write ('SET OFF: ',tempstr : 40,' ',s.size:9,'? ');
  102.          REPEAT
  103.             CH := UPCASE(READKEY);
  104.          UNTIL CH IN ['Y','N'];
  105.          IF CH = 'Y' THEN EFA := (REGS.CL and INDEX_BIT)
  106.          ELSE
  107.          begin
  108.             writeln ('ON':5);
  109.             EXIT;
  110.          end;
  111.       end;
  112.    end
  113.    ELSE
  114.    BEGIN
  115.       if (regs.cl and index_on) = 0 then
  116.       {it is not already on, turn it on?}
  117.       begin
  118.          WRITE ('SET ON : ',TEMPSTR : 40,' ',s.size:9,'? ');
  119.          REPEAT
  120.             CH := UPCASE(READKEY);
  121.          UNTIL CH IN ['Y','N'];
  122.          IF CH = 'Y' THEN EFA := (REGS.CL OR INDEX_BIT)
  123.          ELSE
  124.          begin
  125.             writeln('OFF':5);
  126.             EXIT;
  127.          end;
  128.       end
  129.       else
  130.       begin
  131.          {It is bigger but already on, just list it}
  132.          Writeln ('FILE   : ',tempstr : 40,' ',s.size:9,': ALREADY ON');
  133.          exit;
  134.       end;
  135.    END;
  136.  
  137.  
  138.    {SET ATTRIBUTE BACK WITH INDEX BIT ON}
  139.    WITH REGS DO
  140.    BEGIN
  141.       AH :=$B6;
  142.       AL :=$01;              {set extended attribute}
  143.       DS := SEG(PZSTR);
  144.       DX := OFS(PZSTR);
  145.       CL := EFA;
  146.    END;
  147.    MSDOS(REGS);
  148.  
  149.    WITH REGS DO
  150.    IF ((FLAGS AND FCARRY) = 0) THEN
  151.    begin
  152.       if index_bit = index_on then WRITELN ('ON':5)
  153.                               else writeln ('OFF':5);
  154.    end
  155.    ELSE IF (AL <> 0) THEN WRITELN ('FAIL:':5,AL);
  156.  
  157. END;
  158.  
  159.  
  160.  
  161.  
  162. BEGIN
  163.    CLRSCR;
  164.  
  165.    Writeln ('FLAGBIG - Copyright 1989, Azatar MicroSystems and Lee Drake');
  166.    writeln ('          All rights reserved.  Permission given for ');
  167.    writeln ('          non-commercial use only.  This is a share- ');
  168.    writeln ('          ware program.  If you find it useful please');
  169.    writeln ('          Send $5 to Azatar MicroSystems, 3300 Monroe');
  170.    writeln ('          Avenue, Rochester, NY  14618.              ');
  171.    writeln ('          Any copies of this program must include    ');
  172.    writeln ('          this message in it''s entirety             ');
  173.  
  174.    writeln;
  175.    writeln ('USAGE:  FLAGBIG [#######]                            ');
  176.    writeln ('        Where    ####### = the cutoff point for file ');
  177.    writeln ('        size.                                        ');
  178.    writeln ('Program written in Turbo Pascal 5.5.                 ');
  179.  
  180.    err := 0;
  181.  
  182.    IF PARAMCOUNT > 0 THEN VAL(PARAMSTR(1),DEFAULT_MIN_FILE_SIZE,ERR);
  183.    IF ERR <> 0 THEN DEFAULT_MIN_FILE_SIZE := 500000;
  184.  
  185.    Writeln ('Cutoff point = ',default_min_file_size);
  186.  
  187.    {Note path could be passed in.  Right now uses default drive and all}
  188.    {files on the drive.                                                }
  189.  
  190.    searchengineall ( '\','*.*',ANYFILE,FLAGIT,ERR2);
  191.    SEARCHERRORMESSAGE (ERR2);
  192.  
  193. END.
  194.